package com.example.fufudamowang.recyclerview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;


public class MainActivity extends AppCompatActivity {

    private List<Imagetext>imagetextList=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        init();

        RecyclerView recyclerView= (RecyclerView) findViewById(R.id.rv);
        LinearLayoutManager layoutManager=new LinearLayoutManager(this);


        recyclerView.addItemDecoration(new DividerItemDecoration(this,DividerItemDecoration.class));
        //recyclerView.setLayoutManager(layoutManager);
        RecyclerViewAdapter adapter=new RecyclerViewAdapter(imagetextList);
        recyclerView.setAdapter(adapter);

    }

    private void init(){
        for(int i=0;i<5;i++){
            Imagetext a=new Imagetext("aaa",R.mipmap.ic_launcher);
            imagetextList.add(a);
            Imagetext b=new Imagetext("bbb",R.mipmap.ic_launcher);
            imagetextList.add(b);
            Imagetext c=new Imagetext("ccc",R.mipmap.ic_launcher);
            imagetextList.add(c);
            Imagetext d=new Imagetext("ddd",R.mipmap.ic_launcher);
            imagetextList.add(d);
            Imagetext e=new Imagetext("eee",R.mipmap.ic_launcher);
            imagetextList.add(e);
            Imagetext f=new Imagetext("fff",R.mipmap.ic_launcher);
            imagetextList.add(f);
        }

    }

    private class DividerItemDecoration extends RecyclerView.ItemDecoration {
        public DividerItemDecoration(MainActivity mainActivity, Object p1) {
        }
    }
}
